import { defineStore } from 'pinia'

export const useAuthStore = defineStore('auth', {
    state: () => ({
        token: localStorage.getItem('auth_token') || null,
        isAuthenticated: !!localStorage.getItem('auth_token')
    }),
    actions: {
        login(token:string) {
            this.token = token
            this.isAuthenticated = true
            localStorage.setItem('auth_token', token)
        },
        logout() {
            this.token = null
            this.isAuthenticated = false
            localStorage.removeItem('auth_token')
        },
        accountInfo(){
            return {
                name:"超级管理员",
                role:"admin",
                avatar:"身份"
            }
        }
    }
})
